<?php
namespace app\index\model;
use think\Model;
class Authrule extends Model
{
	//根据id查询标识符
    public function getname($id=0){
        $res=model('authrule')->where(['id'=>['=',$id],'status'=>['=',1]])->find()->toArray();
        return $res['name'];
    }
    public function AllData(){
        $res=model('authrule')->select();
        return $res;
    }
    //重命名状态
    public function getStatusAttr($value){
        $audit=[0=>'已禁用',1=>'已启用'];
        return $audit[$value];
    }
    //权限的启用和关闭
    public function updateStatus($id){
        $res=model('authrule')->where(['id'=>['=',$id]])->find()->toArray();
        if($res['status']=="已禁用")
            $status=1;
        else
            $status=0;
        $result = $this->where('id',$id)->update(['status'=>$status]);
        if ($result)
            return true;
        else
            return false;
    }
}